package com.home.viewmodel

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider



class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var timeViewModel: TimeViewModel = ViewModelProvider(this).get(TimeViewModel::class.java)
        timeViewModel.setOnTimeChangeListener(object:TimeViewModel.OnTimeChangeListener{
            override fun onTimeChange(second: Int) {
                runOnUiThread {
                    findViewById<TextView>(R.id.time_tv).text = "Time: $second"
                }

            }
        })
        timeViewModel.startTiming()
    }
}